Repository navigation
fix: reuse only user-supplied values when no values flag is given (#464) - #1087
Open
rishabhvenu wants to merge 1 commit into
Open
rishabhvenu wants to merge 1 commit into
rishabhvenu wants to merge 1 commit into
Conversation
…tabus23#464) Without any --set/--values flag, helm-diff fetched the values of the release with `helm get values --all` and passed them to the render command as --values. That output contains the whole values.yaml of the chart the release was installed from, and a --values file takes precedence over the values.yaml of the new chart. Changes to the chart's own values.yaml were therefore missing from the diff. `helm upgrade` only does that with --reuse-values. By default it reuses just the user-supplied values of the release. Fetch the values without --all in that case, and pass no --values at all when the release has no user-supplied values (`helm get values` prints "null" then). The diff for --reuse-values and --reset-then-reuse-values does not change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #464
helm diff upgradewithout any--set/--valuesflag does not show changes made to the chart's ownvalues.yaml. For a release installed from a local chart, editing a value invalues.yamlgives an empty diff, whilehelm upgradedoes apply the change.Cause
When no value flag is given,
template()incmd/helm.gofetches the values of the release withhelm get values --alland passes them tohelm templateas--values. With--allthat output is the fully coalesced values, so it contains the wholevalues.yamlof the chart the release was installed from. A--valuesfile takes precedence over thevalues.yamlof the new chart, so every changed default is overridden by its old value. (The root cause was worked out by @antoineozenne in the issue.)This is what
helm upgrade --reuse-valuesdoes, not whathelm upgradedoes by default. InreuseValues()the default case is only:current.Configholds the user-supplied values. The chart's values are left alone.Fix
Without
--reuse-values, fetch the values without--all, which iscurrent.Config. If the release has no user-supplied values,helm get valuesprintsnull, and no--valuesis passed at all.--reuse-valuesstill uses--all, and--reset-then-reuse-valuesalready fetched without--all. The same code runs withHELM_DIFF_USE_UPGRADE_DRY_RUN=true, so that mode is fixed too.Behaviour change
The default diff now includes changes to the chart's default values. A diff that used to be empty can now show changes, and
--detailed-exitcodethen returns 2 for it. Those are the changeshelm upgrademakes. User-supplied values of the release are still kept, as before.Tests
TestUpgradeCommand_Execution_ReuseValues: the case "existing release without value flags" from fix: skip --reuse-values for a release that is not installed (#481) #1086 expectedhelm get values --all. It now expects the call without--all, since that expectation was this bug. Two new cases coverHELM_DIFF_USE_UPGRADE_DRY_RUNand a release without user-supplied values, wherehelm get valuesprintsnulland no--valuesmay be passed. All cases now also check whether--valuesreaches the render command. The three default-path cases fail on master. The fake helm can print a separate output forhelm get valuesthroughHELM_DIFF_FAKE_VALUES_OUTPUT.--set user=from-install, then changed a default invalues.yamland added a new key. For each row I comparedhelm diff upgradewithhelm upgrade --dry-run=server:HELM_DIFF_USE_UPGRADE_DRY_RUN=true--reset-values--reset-then-reuse-values-f extra.yaml--reuse-valuesBoth Helm versions give the same results. Only the two rows without flags change. With only an existing value edited,
helm diff upgrade --allow-unreleasedprints an empty diff on master and the changed line with this PR.make format,make lintandmake testpass, and golangci-lint v2.14.0 reports 0 issues.Not tested: a kind cluster, so the CI integration job has not been run locally. I did not add a
scripts/issues/464.sh; I can add one if you want it.Not part of this PR
--reuse-values, a key that is new in the chart'svalues.yamlstill appears in the diff, because a--valuesfile can only be merged over the new chart's values and Helm replaces them.HELM_DIFF_USE_UPGRADE_DRY_RUN=true,--reset-valuesis not passed on tohelm upgrade, so a release with user-supplied values keeps them in the diff. That is the same before and after this change.